package leetcode.bfs;

import leetcode.bfs.common.BFSUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode(int x) { val = x; }
 * }
 */

class Solution1379 {
    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
        return BFSUtils.getTargetCopy(original, cloned, target);
    }
}

public class leetcode1379 {
    public static void main(String[] args) {
        Solution1379 solution1379 = new Solution1379();
        Integer[] nums = {7, 4, 3, null, null, 6, 19};
        test1379(solution1379, nums, 3);
        test1379(solution1379, nums, 6);
    }

    private static void test1379(Solution1379 solution1379, Integer[] nums, int targetVal) {
        TreeNode original = TreeUtils.generateLeetcodeTree(nums);
        TreeNode cloned = TreeUtils.generateLeetcodeTree(nums);
        TreeNode target = TreeUtils.getTreeNodeByVal(original, targetVal);
        TreeNode targetCopy = solution1379.getTargetCopy(original, cloned, target);
        System.out.println(targetCopy.val);
    }
}
